package tv.accedo.memory.action;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import tv.accedo.memory.dao.AchiDao;
import tv.accedo.memory.dao.UserDao;

public class ScoreServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
	public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		request.setCharacterEncoding("utf-8"); 
		response.setContentType("text/html;charset=utf-8");
		PrintWriter out = response.getWriter(); 
		System.out.println("Server get one request from client side!"); 
		
		
		String scoreString = request.getParameter("score"); 
		String username = request.getParameter("username");
		int score = Integer.parseInt(scoreString); 
		UserDao userDao = new UserDao(); 
		userDao.addScoreToUser(score, username); 
	}

	public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}

}

